<template>
  <form>
    <table>
      <tr>
        <td>品牌</td>
        <td>
          <select v-model="car.tid">
            <option :value="type.id" v-for="(type,index) in typeList":key="index">{{type.name}}</option>
          </select>
        </td>
      </tr>
      <tr>
        <td>型号</td>
        <td><input type="text" v-model="car.name"/></td>
      </tr>
      <tr>
        <td>价格</td>
        <td><input type="text" v-model="car.price"/></td>
      </tr>
      <tr>
        <td>速度</td>
        <td><input type="text" v-model="car.speed"/></td>
      </tr>
      <tr>
        <td>生产日期</td>
        <td><input type="date" v-model="car.createDate"/></td>
      </tr>
      <tr><td colspan="2">
        <button @click.prevent="updateCar()">修改</button>
        </td>
      </tr>
    </table>
  </form>
</template>

<script>
    export default {
     name: "UpdateCar",
      data(){
       return{
         car:this.$route.query.car,
         typeList:[]
       }
      },
      methods:{
       updateCar(){
         this.car.ct=undefined
         this.axios({
           method:"get",
           url:"/car/updateCar.do",
           params:this.car
         }).then((res)=>{
           alert("修改成功")
           this.$router.push("/")
         })
       }
      },
      created() {
        this.axios({
          method:"get",
          url:"/carType/selectAllType.do"
        }).then((res)=>{
          this.typeList=res.data
        })
      }
    }
</script>

<style scoped>

</style>
